<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.v2.jsp"%>
<style>
#jquery-table td {
	cursor: pointer !important;
	word-break: break-all;
	word-wrap: break-word;
}

.load_bg {
	background: #000;
	opacity: 0.1;
	left: 0px;
	top: 0px;
	position: fixed;
	height: 100%;
	width: 100%;
	overflow: hidden;
	z-index: 10000;
}

.load_img {
	left: 50%;
	top: 180px;
	position: fixed;
	height: 50px;
	overflow: hidden;
	z-index: 20000;
}

a.check {
	margin-bottom: 10px;
}

@media ( min-width : 768px) and (max-width: 1200px) {
	.backup-text {
		width: 100px !important;
	}
}
</style>
</head>
<body class="no-skin">
	<div class="load_bg" style="display: none;"></div>
	<img src="http://img.tuanzidai.cn/commentloading.gif" class="load_img"
		style="display: none" />
	<div class="page-content">
		<div id="test"></div>
		<form id="queryForm">
		    <input type="hidden" name="type" value="${param.type}"/>
		    <input type="hidden" name="order_id" value="${param.order_id}"/>
			<div class="page-content-area">
				<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
			</div>
		</form>
	</div>
<%@ include file="/common/common-js.jsp"%>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>

<script type="text/javascript">

	function loadlist() {
		var form = document.forms["queryForm"];
		form.action = ctx + "/loanorder/exportData.action";
		form.submit();
	}
	
	//【查询】按钮Click事件
	function query_any() {
		$("#output").show();
		if(jqTable != null){
			jqTable.fnDraw();
		} else{
			loaddata();
		}
	}
    
	var jqTable = null;
	var loaddata = function() {
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable({
				//数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
				"columnDefs" : [
						{
							"title" : '订单编号',
							"targets" : [ 0 ],
							"data" : "order_id",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : '请求JSON',
							"targets" : [ 1 ],
							"data" : "request_json",
							"class" : "center",
							"bSortable" : false,
							"width" : "50px",
						},
						{
							"title" : 'URL',
							"targets" : [ 2 ],
							"data" : "url",
							"class" : "center",
							"bSortable" : false,
							"width" : "60px",
						},
						{
							"title" : '返回JSON',
							"targets" : [ 3 ],
							"data" : "response_json",
							"class" : "center",
							"bSortable" : false,
							"width" : "60px",
							"render": function(value, type, row) {
								if(value != null){
								   return value;
								} else{
								   return "--";
								}
							}
						},
				 ],
				 "sAjaxSource": ctx + "/loanorder/requestJson.action?rand=" + Math.random(),//数据源URL
				 "fnServerData" : function(sSource, aoData,fnCallback) {
					  var data = $('#queryForm').serializeObject();
					  data.aoData = JSON.stringify(aoData);
					  $.ajax({
							"type" : "POST",
							"dataType" : 'json',
							"url" : sSource,
							"data" : data,
							"success" : function(resp) {
								fnCallback(resp);
								initListPage();
							},
							"error" : function(XMLHttpRequest,
									textStatus, errorThrown) {
							},
							"complete" : function() {
								$(".load_bg,.load_img").hide();
							}
						});
				},
				"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
	  				//=====================这里实现行双击事件======================//
				    var col1 = $(nRow).children().eq(1);
				    var col2 = $(nRow).children().eq(2);
				    var col3 = $(nRow).children().eq(3);
	  				
	  				$(col1).on('dblclick',function(){
	  					copyText(aData.request_json);
	  				});
	  				
	  				$(col2).on('dblclick',function(){
	  					copyText(aData.url);
	  				});
	  				
	  				$(col3).on('dblclick',function(){
	  					copyText(aData.response_json);
	  				});
	  			},
				"sScrollXInner" : "100%",
				"sScrollY" : "100%",//如果不设置，IE会有问题
				"aaSorting" : [ [ 0, "asc" ] ] //初始化加载，默认按第几列排序、排序方式（列从0开始计算）
			});
		});
	}
	
	function copyText(data) {
		
		var aux = document.createElement("input");
		// 设置元素内容
		aux.setAttribute("value", data);
		// 将元素插入页面进行调用
		document.body.appendChild(aux);
		// 复制内容
		aux.select();
		// 将内容复制到剪贴板
		document.execCommand("copy");
		// 删除创建元素
		document.body.removeChild(aux);
		alert("复制成功");
	}

	//时间控件
	jQuery(function($) {
		$(".date-picker").datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});
	});

	$(document).ready(function() {
		query_any();
	});
</script>

</body>
</html>